package com.gongpingjialoan.widget;

import com.gongpingjialoan.R;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ScoreDialog extends Dialog
{
    
    private ScoreDialog mySelf = this;
    
    Context context;
    
    private Button yes_layout;
    
    private Button no_layout;
    
    private TextView tips_txt;
    
    private int mType = 0;
    
    OnDialogResult onDialogResult;
    
    public ScoreDialog(Context context, int type)
    {
        super(context, R.style.dialogs);
        this.context = context;
        this.mType = type;
    }
    
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.score_dialog);
        this.setCanceledOnTouchOutside(false);
        this.setCancelable(false);
        yes_layout = (Button)this.findViewById(R.id.yes_btn);
        no_layout = (Button)this.findViewById(R.id.no_btn);
        tips_txt = (TextView)this.findViewById(R.id.tips_txt);
        if (mType == 1)
        {
            tips_txt.setText("客官，公平价过了您的试用期吗？");
            no_layout.setText("有待观察");
        }
        else if (mType == 2)
        {
            tips_txt.setText("客官，赏公平价一个好评呗~");
            no_layout.setText("有待观察");
        }
        else
        {
            tips_txt.setText("客官，公平价迫切需要您的支持~");
            no_layout.setText("不再提示");
        }
        yes_layout.setOnClickListener(new android.view.View.OnClickListener()
        {
            public void onClick(View v)
            {
                if (onDialogResult != null)
                {
                    onDialogResult.onresult(1);
                }
                mySelf.dismiss();
            }
        });
        no_layout.setOnClickListener(new android.view.View.OnClickListener()
        {
            public void onClick(View v)
            {
                if (onDialogResult != null)
                {
                    onDialogResult.onresult(2);
                }
                mySelf.dismiss();
            }
        });
    }
    
    public int getType()
    {
        return mType;
    }
    
    public OnDialogResult getOnDialogResult()
    {
        return onDialogResult;
    }
    
    public void setOnDialogResult(OnDialogResult onDialogResult)
    {
        this.onDialogResult = onDialogResult;
    }
    
    public interface OnDialogResult
    {
        void onresult(int result);
    }
}
